package com.shop.loan.controller;

import com.shop.loan.model.common.Constant;
import com.shop.loan.model.common.ResResult;
import com.shop.loan.model.Classify;
import com.shop.loan.model.vo.ClassifyVo;
import com.shop.loan.service.ClassifyService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@Api(value = "商品类目", tags = "商品类目")
@RestController
@RequestMapping(Constant.appPrefex + "/classify")
public class ClassifyController {

    @Resource
    ClassifyService classifyService;

    @ApiOperation("类目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "topClassifyId", value = "上级类目  0：查询一级类目   >0:查询该类目下级"),
    })
    @ApiResponses({
            @ApiResponse(code = 1, message = "成功", response = Classify.class)
    })
    @PostMapping("/list")
    public ResResult list(@ApiIgnore ClassifyVo classifyVo) {
        if(classifyVo.getTopClassifyId() == null){
            classifyVo.setTopClassifyId(0L);
        }
        return classifyService.list(classifyVo);
    }

}
